package hao.itheima.service.impl;

import hao.itheima.entity.EmpLog;
import hao.itheima.mapper.EmpLogMapper;
import hao.itheima.service.EmpLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

@Service
public class EmpLogServiceImpl implements EmpLogService {

    @Autowired
    private EmpLogMapper empLogMapper;

    // Suspending current transaction : 挂起当前事务

//    @Transactional(propagation = Propagation.REQUIRED) // 默认加入
    @Transactional(propagation = Propagation.REQUIRES_NEW) // 创建新的事务, 不过调用方法是否有事务,都创建
    @Override
    public void insertLog(EmpLog empLog) {
        empLogMapper.insert(empLog);
    }
}
